package cn.stylefeng.guns.sys.modular.system.quartz.task;

import cn.stylefeng.guns.sys.modular.system.model.params.AttendAuditDdSupervisorParam;
import cn.stylefeng.guns.sys.modular.system.service.AttendEmployeeMonthService;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

//作业不并发
@DisallowConcurrentExecution
@Component
public class SynchronousAttendEmployeeMonthToBtyArchives  implements Job {
    @Resource
    private AttendEmployeeMonthService attendEmployeeMonthService;
    private Logger logger = LoggerFactory.getLogger(SynchronousAttendEmployeeMonthToBtyArchives.class);
    @Override
    public void execute(JobExecutionContext arg0) throws JobExecutionException {
        logger.info("======= 这是跑了一个定时任务,考勤数据同步回人事数据表  ====");
        AttendAuditDdSupervisorParam param = new AttendAuditDdSupervisorParam();
        //默认创建考勤的日期是上个月
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("YYYYMM");
        String attendMonth = sdf.format(attendEmployeeMonthService.calculateMonth(date,-1));
        param.setAttendMonth(attendMonth);
        Map<String,String> map  =attendEmployeeMonthService.synchronousAttendEmployeeMonthToBtyArchives(param);
        logger.info("======= bakTableName:"+map.get("bakTableName"));
        logger.info("======= employee:"+map.get("employee"));
        logger.info("======= shop:"+map.get("shopSize"));
        logger.info("======= size:"+map.get("size"));
        logger.info("======= sizeforEmpNew:"+map.get("sizeforEmpNew"));

    }

}
